<?php

namespace app\admin\controller\api;

use app\admin\library\DistinguishAddress;
use app\common\model;

/**
 * 学科
 * @internal
 */
class Subject extends Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 学科列表
     *
     * @param school_id int 学校id
     *
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $school_id = $this->request->request('school_id');

        $list = model\Subject::where('school_id', $school_id)->field('id,name')->select();

        $this->success('', $list);
    }

    /**
     * 根据ids 获取学科信息
     */
    public function profile()
    {
        $ids = $this->request->request('ids/a');
        $list = model\Subject::whereIn('id', $ids)->column('id,name,type', 'id');
        $this->success('', $list);
    }


}